var t, e = getApp(), a = "plugin.store-cashier.frontend.boss.child-store.getStoreOrderList";

Page({
    data: {
        language: "",
        store_info: {},
        store_count: {},
        tabArr: [ "门店订单", "收银台订单" ],
        currentIndex: 0,
        store_order_show: !1,
        cashier_order_show: !1,
        storeList: [],
        store_loading: !1,
        store_allLoaded: !1,
        store_goload: !0,
        store_isLoadMore: !0,
        store_page: 1,
        store_total_page: 0,
        cashierList: [],
        cashier_loading: !1,
        cashier_allLoaded: !1,
        cashier_goload: !0,
        cashier_isLoadMore: !0,
        cashier_page: 1,
        cashier_total_page: 0,
        vedioSrc: "",
        audioAction: {
            method: "play"
        },
        tabShowin: !1,
        open_store_balance: !1,
        open_store_show: !1,
        balanceInfo: [],
        page: 1
    },
    onLoad: function(t) {
        this.getStoreInfo(), this.getStoreList();
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        }), this.audioCtx = wx.createAudioContext("yp");
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.open_store_show) {
            if (this.data.page >= this.data.last_page) return void console.log("没有更多了。。");
            wx.showLoading({
                title: "加载更多"
            }), this.getMoreBalance();
        } else this.data.store_isLoadMore ? this.getMoreStoreList() : wx.showToast({
            title: "没有更多数据",
            icon: "none"
        });
    },
    onShareAppMessage: function() {},
    getStoreInfo: function() {
        var t = this, a = e.getNetAddresss("plugin.store-cashier.frontend.boss.child-store.index");
        a += "&store_id=" + this.options.id, e._getNetWork({
            url: a,
            success: function(e) {
                var a = e.data;
                1 === a.result ? (a.data.open_store_balance && (t.setData({
                    open_store_balance: a.data.open_store_balance,
                    open_store_show: !0
                }), t.getBalance()), t.setData({
                    store_info: a.data.store,
                    store_count: a.data.statistics,
                    tabShowin: !0
                }), t.getCashierList(t.data.store_info.cashier_id)) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    toggle: function(t) {
        var e, a, s = t.detail.name, o = !1;
        "3" == s ? (o = !0, e = !1, a = !1, this.setData({
            page: 1,
            balanceInfo: []
        }), this.getBalance()) : "2" == s ? (a = !0, e = !1, o = !1) : "1" == s && (e = !0, 
        a = !1, o = !1), this.setData({
            open_store_show: o,
            cashier_order_show: a,
            store_order_show: e
        });
    },
    getBalance: function() {
        var t = this, a = e.getNetAddresss("plugin.store-cashier.frontend.store.balance.award.boss");
        a += "&store_id=" + this.options.id + "&page=" + this.data.page, e._getNetWork({
            url: a,
            success: function(e) {
                var a = e.data;
                1 === a.result ? t.setData({
                    balanceInfo: a.data.list.data,
                    last_page: a.data.list.last_page
                }) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreBalance: function() {
        var t = this;
        this.setData({
            page: this.data.page + 1
        });
        var a = e.getNetAddresss("plugin.store-cashier.frontend.store.balance.award.boss");
        a += "&store_id=" + this.options.id + "&page=" + this.data.page, e._getNetWork({
            url: a,
            success: function(e) {
                wx.hideLoading({
                    success: function(t) {}
                });
                var a = e.data;
                if (1 === a.result) {
                    var s = a.data.list.data;
                    t.data.balanceInfo = t.data.balanceInfo.concat(s), t.setData({
                        balanceInfo: t.data.balanceInfo,
                        last_page: a.data.list.last_page
                    });
                } else wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                wx.hideLoading({
                    success: function(t) {}
                }), console.log(t);
            }
        });
    },
    getStoreList: function() {
        var t = this, s = e.getNetAddresss(a);
        s += "&store_id=" + this.options.id + "&page=" + this.data.store_page, e._getNetWork({
            url: s,
            success: function(e) {
                var a = e.data;
                1 === a.result ? t.setData({
                    storeList: a.data.data,
                    store_total_page: a.data.last_page
                }) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreStoreList: function() {
        var t = this;
        if (this.data.store_page != this.data.store_total_page) if (this.data.store_page >= this.data.store_total_page) this.setData({
            store_loading: !0,
            store_allLoaded: !0
        }); else {
            var s = this.data.store_page + 1;
            this.setData({
                store_page: s
            });
            var o = e.getNetAddresss(a);
            o += "&store_id=" + this.options.id + "&page=" + this.data.store_page, e._getNetWork({
                url: o,
                success: function(e) {
                    var a = e.data;
                    if (1 === a.result) {
                        var s = t.data.storeList.concat(a.data.data);
                        t.setData({
                            storeList: s,
                            store_loading: !1,
                            store_allLoaded: !1
                        });
                    } else {
                        var o = t.data.store_page - 1;
                        t.setData({
                            store_page: o,
                            store_loading: !0,
                            store_allLoaded: !0,
                            store_isLoadMore: !1
                        });
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    getCashierList: function(t) {
        var a = this, s = e.getNetAddresss("plugin.store-cashier.frontend.boss.child-store.getCashierOrderList");
        s += "&cashier_id=" + t + "&page=" + this.data.cashier_page, e._getNetWork({
            url: s,
            success: function(t) {
                var e = t.data;
                1 === e.result ? a.setData({
                    cashierList: e.data.data,
                    cashier_total_page: e.data.last_page
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    isOpenAudio: function() {
        var t = this, a = e.getNetAddresss("plugin.store-cashier.frontend.boss.voice-broadcast.verifyOpenAudio");
        a += "&store_id=" + this.options.id, e._getNetWork({
            url: a,
            success: function(e) {
                var a = e.data;
                1 === a.result ? 1 == a.data.audio_open && t.getAudio() : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getAudio: function() {
        var a = this;
        t = setInterval(function() {
            var t = e.getNetAddresss("plugin.store-cashier.frontend.boss.voice-broadcast.index");
            t += "&store_id=" + a.options.id, e._getNetWork({
                url: t,
                success: function(t) {
                    var e = t.data;
                    1 === e.result ? (a.setData({
                        vedioSrc: e.data.url
                    }), a.audioPlay()) : wx.showToast({
                        title: e.msg,
                        icon: "none"
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }, 5e3);
    },
    audioPlay: function() {
        var t = getCurrentPages(), a = {
            url: t[t.length - 1].route
        }, s = e.getNetAddresss("member.member.wxJsSdkConfig");
        e._postNetWork({
            url: s,
            data: a,
            success: function(t) {
                var e = t.data;
                0 === e.result && wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    closeTimeInterval: function() {
        console.log("dsdsdsdsds"), clearInterval(t);
    }
});